package com.cncsi.web;

import com.cncsi.dao.MenuRepositoty;
import com.cncsi.entity.Menu;
import com.cncsi.entity.Restaurant;
import com.cncsi.service.MenuService;
import com.cncsi.service.RestaurantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * Created by 1N on 2018/9/11.
 */
@Controller
@RequestMapping("/menu")
public class MenuController {

    @Autowired
    private MenuService menuService;
    @Autowired
    private RestaurantService restaurantService;

    @RequestMapping("/toMenuIndex")
    public String init(Map<String,Object> map){
        List<Menu> menuList = menuService.getMenu();
        List<Restaurant> restaurantList = restaurantService.getRestaurantList();
        Menu menu = new Menu();
        map.put("menuList",menu.cleanRelation(menuList));
        map.put("restaurantList",restaurantList);
        return "menu/menu_index";
    }

//    @ResponseBody
//    @RequestMapping(value = "/saveMenu",method = RequestMethod.POST)
//    public String saveMenu(Menu menu){
//        String str = menuService.saveMenu(menu);
//        return str;
//    }
}
